from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2
import os
import getpass
USER_NAME = getpass.getuser()
def post(file_path):
    if not os.path.exists(file_path):
        raise IOError("File not exist")
        return False
    register_openers()
    datagen, headers = multipart_encode({"report_files": open(file_path, "rb"), "reporter" : USER_NAME})
    request = urllib2.Request("http://10.127.10.62/CrashReporter/file_upload.php", datagen, headers)
    return urllib2.urlopen(request).read()
    